/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.system.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
import java.util.List;

/**
* @website https://el-admin.vip
* @description /
* @author whj
* @date 2021-06-03
**/
@Entity
@Data
@Table(name="file_detail")
public class FileDetail implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "key")
    private Long id;

    @Column(name = "file_name")
    @ApiModelProperty(value = "文件名")
    private String fileName;

    @Column(name = "file_path")
    @ApiModelProperty(value = "文件json路径")
    private String filePath;

    @Column(name = "status",nullable = false)
    @NotNull
    @ApiModelProperty(value = "文件是否被识别 若被修改 ")
    private Integer status;

    @Column(name = "result_path")
    @ApiModelProperty(value = "识别结果路径，如果json被修改过重新识别，则继续添加路径以，分割")
    private String resultPath;

    @Column(name = "update_time")
    @ApiModelProperty(value = "修改时间，json若被修改则")
    private Timestamp updateTime;

    @Column(name = "result_image_path")
    @ApiModelProperty(value = "识别结果图片保存路径")
    private String resultImagePath;

//    @ManyToMany
//    @JoinTable(name = "file_task",
//            joinColumns = {@JoinColumn(name = "file_id",referencedColumnName = "id")},
//            inverseJoinColumns = {@JoinColumn(name = "task_id",referencedColumnName = "id")})
//    @ApiModelProperty(value = "所属用户")
//    private List<Task> tasks;

    public void copy(FileDetail source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}